package com.lucky.carcodepro.controller;

import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.lucky.carcodepro.domain.request.LoginRequest;
import com.lucky.carcodepro.domain.response.Response;
import com.lucky.carcodepro.service.UserInfoService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * UserInfoController
 * <p>
 * 描述：
 *
 * @author Annie
 * @version 2024/10/2 16:06
 */
@Slf4j
@RestController
@AllArgsConstructor
@Tag(name = "用户服务")
@RequestMapping("/demo/user/")
public class UserInfoController
{

    private final UserInfoService userInfoService;

    /**
     * 登录
     */
    @PostMapping("login")
    public Response<SaTokenInfo> silentLogin(@Validated @RequestBody LoginRequest request)
    {
        userInfoService.wxSilentLogin();
        return Response.success(StpUtil.getTokenInfo());
    }
}
